package id.co.rho.scoring.cid.framework.math.evaluator.model.visitor;

import id.co.rho.scoring.cid.framework.math.evaluator.model.BinaryOpValueNode;
import id.co.rho.scoring.cid.framework.math.evaluator.model.MEValueNode;

import java.math.BigDecimal;

/**
 * Created by IntelliJ IDEA.
 * User: bungrudi
 * Date: 9/14/11
 * Time: 4:26 PM
 */
public class SubCalculation implements NodeEvaluator {
    @Override
    public BigDecimal calculate(MEValueNode node, NodeWalkerExecutor context) {
        BinaryOpValueNode n = (BinaryOpValueNode) node;
        BigDecimal valLeft = context.getResultMap().get(n.getLeftOp());
        BigDecimal valRight = context.getResultMap().get(n.getRightOp());
        return valLeft.subtract(valRight);
    }
}
